package com.code.util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.atomic.AtomicInteger;

public class PrimaryKeyUtil {

	private static SimpleDateFormat sdf = new SimpleDateFormat("yyMMddHHmm");
	private static AtomicInteger uniqueId = new AtomicInteger(100000);
	
	private static String value = "";

	public static long generatePrimaryKey(){
		if (!sdf.format(new Date()).equals(value)) {
			value = sdf.format(new Date());
			uniqueId.set(100000);
		}
		
		return Long.parseLong(value + "" + uniqueId.incrementAndGet());
	}
}
